package com.bookSystem.service.Impl;/*
 * @Author:lsx
 * @Date:2024/9/15--09--15--20:55
 *
 */

import com.bookSystem.dao.Impl.UserDaoImpl;
import com.bookSystem.dao.UserDao;
import com.bookSystem.entity.User;
import com.bookSystem.service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
    @Override
    public int login(String account, String password) {
        if(userDao.login(account,password)==1){
            //登录成功
            return 1;
        }
        if (userDao.selectByAccount(account)==1){
            //账号存在
            return 2;
        }
        //账号不存在
        return 0;
    }

    @Override
    public User selectByAccountAndUserPass(String account, String password) {
        return userDao.selectByAccountAndUserPass(account,password);
    }

    @Override
    public int register(String username, String password, String account) {

        if(userDao.selectByAccount(account)==1){
            //账号存在
            return 1;
        }else if(userDao.register(username,password,account)==1){
            //注册成功
            return 2;
        }
        //注册失败
        return 0;
    }
}
